#!/usr/bin/env python
# -*- coding: utf-8 -*-

# @Time     :2020/08/15
# @Author   :Changshu
# @File     :practice_67.py
# 67. 二进制求和,给你两个二进制字符串，返回它们的和（用二进制表示）。
'''
def addBinary(a: str, b: str) -> str:
	aLength = len(a)
	bLength = len(b)
	ans = 0  # 进位
	r=''
	if aLength < bLength:
		for i in range(0, bLength - aLength):
			a = '0' + a
	elif aLength > bLength:
		for i in range(0, aLength - bLength):
			b = '0' + b
	for i in range(len(a) - 1, -1, -1):
		a_int = int(a[i])
		b_int = int(b[i])
		s = a_int + b_int+ans
		ans=s>>1
		s=s%2
		r=str(s)+r
	if ans==1:
		r="1"+r
	return r
'''

'''最简单的方法'''
def addBinary(a: str, b: str) -> str:
	return "{0:b}".format(int(a,2)+int(b,2))

if __name__ == '__main__':
	a = "0"
	b = "1011"
	print(addBinary(a, b))
